package com.code4j.tree;

import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JLabel;

public class Client {
	public static void main(String[] args) {
		//TreeBuilder builder = new TreeBuilder();
		BinaryTree tree = new BinaryTree();
		tree.clearAll();
		//builder.fillBinaryTree(tree);
		//BinaryTree tree = builder.getTree();

		//		for (int i = 0; i < args.length; i++) {
		//			tree.addNode(args[i]);
		//		}
		
		BinaryTreeView view = new BinaryTreeView();
		JLabel label = new JLabel();
		BinaryTreeStatus status = new BinaryTreeStatus();
		
		tree.addObserver(view);
		tree.addObserver(status);
		
		tree.refreshTree();
		
		Controller controller = new Controller();
		
		controller.setTree(tree);
		controller.SetView(view);
		controller.setTipsView(label);
		
		
		JFrame f = new JFrame("BinaryTree");
		f.getContentPane().add(view);
		
		f.add(label,BorderLayout.NORTH);
		f.add(status,BorderLayout.SOUTH);
		// create and add an event handler for window closing event
		f.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		});
		f.setBounds(50, 50, 300, 300);
		f.setVisible(true);
	}
}
